package yf.mall.dao;

import com.yf.dao.BaseDao;
import org.apache.ibatis.annotations.Param;
import yf.mall.entity.MallOrderEntity;
import yf.mall.vo.MallOrderVo;
import org.apache.ibatis.annotations.Mapper;

import java.math.BigDecimal;
import java.util.List;

/**
 * 商品订单Dao
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Tue Aug 13 14:26:20 CST 2019
 */
@Mapper
public interface MallOrderDao extends BaseDao<MallOrderEntity> {

    List<MallOrderVo> queryListVo(MallOrderVo mallOrderVo);

    MallOrderVo getVo(Long id);

    List<MallOrderVo> findByUserId(@Param("userId") Long userId,@Param("orderType")Integer orderType,@Param("busType")Integer busType);

    //找出未发货的订单
    List<MallOrderEntity> findNotDelivered(@Param("fromUserId") Long fromUserId);

    //找出商城下单且支付了的
    List<MallOrderEntity> findUserPaid(@Param("userId") Long userId, @Param("startDate") String startDate, @Param("endDate") String endDate);

    //更新状态
    void updateDelivering(@Param("ids") List<Long> ids);

    MallOrderVo getVoByOrderNo(String orderNo);

    //根据订单编号查找
    MallOrderEntity findByOrderNo(String orderNo);


    List<MallOrderEntity> findByRemark(String orderNo);

    //恢复定点杆
    void renew(@Param("fromUserId") Long fromUserId);

    List<MallOrderVo> queryByUserIdAndStatus(@Param("userId") Long userId,@Param("status") int status);

   MallOrderEntity findByRemarkAndBusType(@Param("orderNo") String orderNo, @Param("busType") Integer busType);

    List<MallOrderVo> queryByUserIdAndPayStatus(@Param("userId")Long userId, @Param("orderStatus") Integer orderStatus, @Param("payStatus")Integer payStatus);

    Integer total(@Param("userId") Long userId, @Param("orderStatus") int orderStatus, @Param("payStatus") int payStatus);

    List<MallOrderVo> findByFromUserId(Long userId, Integer orderStatus, int payStatus);

    List<MallOrderEntity> findByYerterday(String orderTime);

    Integer totalOrderNum(Long userId);

    Integer todayOrderNum(Long userId);

    BigDecimal totalPrice(Long userId);

    BigDecimal todayPrice(Long userId);

    List<MallOrderEntity> autoCancel();

    Integer sumBuyOrderByPid(Long userId);
}
